package de.fmannan.addbook;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

import de.fmannan.addbook.views.ContactTableView;
import de.fmannan.addbook.views.ContactTreeView;

/**
 * 
 * @author fmannan
 * 
 * Perspective is defined by its extension identifier. The extension gives the
 * perspective a human-readable name and specifies a class that defines the
 * layout of the perspective. A perspective factory provides the initial layout
 * for a perspective. When a perspective is needed, the factory is created and
 * passed an IPageLayout to which views are added. The factory is then
 * discarded. As the user rearranges the contents of the perspective, the
 * Workbench saves the settings on exit and restores them at startup (if so
 * configured).
 * 
 * All views that should be added to the default layout should be declared in
 * the createInitialLayout method.
 */
public class Perspective implements IPerspectiveFactory {

	/**
	 * Creates the initial layout which is displayed when starting the
	 * application. Views added to a perspective using IPageLayout.addView()
	 * inherit various default behaviors that allow them to be moved, un-docked,
	 * closed, minimized, and maximized. Using IPageLayout.addStandaloneView(),
	 * however, adds a standalone view. Standalone views hide the title area,
	 * thus preventing the view from being closed, moved, etc.
	 * 
	 */
	public void createInitialLayout(IPageLayout layout) {
		/*
		 * That's the reference ID for the View
		 */
		String editorArea = layout.getEditorArea();
		
		layout.setEditorAreaVisible(false);
		
		/*
		 * IPageLayout contains several methods for defining the layout of a
		 * perspective. Everything added to a perspective is related to
		 * something else. Here, the editor area is used as the base for placing
		 * the Contacts view.The Contacts view is added to the left of the
		 * editor area and is given all available space in the page by
		 * specifying 1.0f as the layout ratio. The ratio describes how to
		 * divide the available space between the Contacts view and its
		 * reference part, in this case, the editor area
		 */
		layout.addStandaloneView(ContactTreeView.ID, true, IPageLayout.LEFT, 0.3f, editorArea);
		layout.addStandaloneView(ContactTableView.ID, true, IPageLayout.BOTTOM, 0.7f, editorArea);
		
	}
}
